package com.calvin.study.multithread.queue;

import java.util.concurrent.ArrayBlockingQueue;

public class ArrayBlockingQueueDemo {

	public static void main(String[] args) {
		ArrayBlockingQueue<String> q = new ArrayBlockingQueue<String>(2);
		
		for (int i = 1, len = 10; i <= len; i++) {
			String index = String.valueOf(i);
			new Thread(() -> {
				 try {
					q.put(index);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}, String.valueOf(i)).start();
		}
		
		
//		while (Thread.activeCount() > 2) {
//			Thread.yield();
//		}
		
		System.out.println(q.peek());
		System.out.println(q.peek());
		
		//q.remove();

		
	}

}
